<%@ page import="sun.security.mscapi.KeyStore" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.DriverManager" %><%--
  Created by IntelliJ IDEA.
  User: 呵呵
  Date: 2018/6/7
  Time: 17:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>个人中心</title>
</head>
<body>
<%
    class Myself {
        private String myProfile;                   //我的资料
        private String release;                     //我的发布
        private String route;                       //行程
        private String photo;                       //相册
        private String money;                       //钱包
        private String travels;                     //游记
        private String focus;                       //关注
        private String collect;                     //收藏
        private String fans;                        //粉丝

        // alt + insert
        public Myself(String myProfile, String release, String route, String photo, String money, String travels, String focus, String collect, String fans) {
            this.myProfile = myProfile;//this表示类或者对象的所有者
            this.release = release;
            this.route = route;
            this.photo = photo;
            this.money = money;
            this.travels = travels;
            this.focus = focus;
            this.collect = collect;
            this.fans = fans;
        }
    }

    List<Myself> list = new ArrayList<Myself>();


    // 3 + 1
    Connection connection = null;
    Statement statement = null;
    ResultSet resultSet = null;
//数据库的名字需更改
    String sql = "select * from t_users";

    Class.forName("com.mysql.jdbc.Driver");

    connection = DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/",
            "root",
            "123456"
    );

    statement = connection.createStatement();

    resultSet = statement.executeQuery(sql);

    while (resultSet.next()) {

        String myself = resultSet.getString(1);
        String username = resultSet.getString(2);
        String password = resultSet.getString(3);

//        Myself user = new Myself(String,);
//        list.add(user);

    }
    resultSet.close();
    statement.close();
    connection.close();


// 221
    for (Myself myself : list) {

        out.write("<tr>" +
                "<td>" + myself.myProfile + "</td><td>" + myself.release + "</td>" +
                "<td>" + myself.route + "</td>" +
                "<td><a href='deleteUserHandler.jsp?id=" + myself.id + "'>删除</a></td>" +
                "<td><a href='updateUser.jsp?id=" + myself.id + "&username=" + myself.username + "&password=" + myself.password + "'>更新</a></td>" +
                "</tr>");
    }
//
//        for (int i = 0; i < 10; i++) {
//            // alt + shift + 向上箭头
//            // ctrl + alt + L
//            out.write("<tr><td>" + i + "</td><td>Jhon</td><td>123</td></tr>");
//        }
%>

</body>
</html>
